<?php

namespace app\advertisement\logic;

use think\facade\Db;
use think\facade\Cache;
use util\Excel;
use think\exception\ValidateException;
use think\facade\Log;
use util\Token;
use util\Upload;
use think\cache\driver\Redis;

class AdvertisementLogic
{
    public function __construct()
    {
        
    }

    /**
     * @param $params
     * @return \think\response\Json
     * @throws \think\db\exception\DbException
     * @desc 列表
     * @author zhangheng
     */
    public function index($params = [])
    {

        $limit = $params['limit'] ?? 10;
        $advertiser_id = $params['advertiser_id'] ?? "";
        $createtime = $params['createtime'] ?? "";
        $platform_id = $params['platform_id'] ?? 0;
        $admin_id = $params['admin_id'] ?? 0;
        $shop_id = $params['shop_id'] ?? 0;
        $type_name = $params['type_name'] ?? 0;
        $ConfirmStatus = $params['ConfirmStatus'] ?? "-1";
        $ConfirmStatusOperate = $params['ConfirmStatusOperate'] ?? "-1";
        $ProxyOwnership = $params['ProxyOwnership'] ?? "";

        // update  2024-10-24 运营产看自己账号;
        $adminId     = $params['adminId'] ?? '';
        $group_id    = $params['group_id'] ?? '';

        $where = [];
        $where[] = ['type', '=', 0];

        if (!empty($createtime)) {
            $where[] = ['stat_time', '>=', strtotime($createtime['0'])];
            $where[] = ['stat_time', '<=', strtotime($createtime['1']) + 3600*24-1];
        }else{
            // $yesterday = strtotime(date('Y-m-d', strtotime('-1 day') - timezone())); 
            // $where[] = ['stat_time', '>=', $yesterday];
            // $where[] = ['stat_time', '<=', $yesterday + 3600*24-1];
        }


        //2024-10-24  运营产看自己账号;
        if(in_array($group_id,[11,17,20,19])){
            $where['admin_id'] = $adminId;
        }
        
        //快捷时间开始
        //customDate优先
        $customDate = $params['customDate'] ?? 0;
        if(!empty($customDate)){
            switch ($customDate) {
                case '1':
                    //实时
                    $yesterday = date('Y-m-d', time() - timezone());  
                    $midnightYesterday = strtotime($yesterday . ' 00:00:00');
                    $endOfYesterday  = strtotime($yesterday . ' 23:59:59');
                    $where[]  = ['stat_time', '>=', $midnightYesterday];
                    $where[]  = ['stat_time', '<', $endOfYesterday]; 

                    break;
                case '2':
                    $yesterday = date('Y-m-d', strtotime('-1 day') - timezone());
                    $midnightYesterday = strtotime($yesterday . ' 00:00:00');
                    $endOfYesterday  = strtotime($yesterday . ' 23:59:59');
                    $where[]  = ['stat_time', '>=', $midnightYesterday];
                    $where[]  = ['stat_time', '<', $endOfYesterday]; 

                    break;
                case '3':
                    $yesterday = strtotime(date('Y-m-d', time() - timezone()));  
                    $yesterdayEnd = strtotime(date('Y-m-d', strtotime('-6 day') - timezone()));  
                    $where[] = ['stat_time', '<', $yesterday];
                    $where[] = ['stat_time', '>=', $yesterdayEnd];

                    break;
                default:
                    $yesterday = date('Y-m-d', strtotime('-1 day') - timezone());
                    $midnightYesterday = strtotime($yesterday . ' 00:00:00');
                    $endOfYesterday  = strtotime($yesterday . ' 23:59:59');
                    $where[]  = ['stat_time', '>=', $midnightYesterday];
                    $where[]  = ['stat_time', '<', $endOfYesterday]; 
            }
        }
        //快捷时间结束

        if (!empty($advertiser_id)) {
            $where[] = ['advertiser_id', 'like', '%' . $advertiser_id . '%'];
        }
        if (!empty($status)) {
            $where[] = ['status', '=', $status];
        }
        switch ($ConfirmStatus) {
            case '0':
                $where[] = ['ConfirmStatus', '=', $ConfirmStatus];
                break;
            case '1':
                $where[] = ['ConfirmStatus', '=', $ConfirmStatus];
                break;
            default:
        }
        switch ($ConfirmStatusOperate) {
            case '0':
                $where[] = ['ConfirmStatusOperate', '=', $ConfirmStatusOperate];
                break;
            case '1':
                $where[] = ['ConfirmStatusOperate', '=', $ConfirmStatusOperate];
                break;
            default:
        }
        if (!empty($platform_id)) {
            $where[] = ['platform_id', '=', $platform_id];
        }
        if (!empty($ProxyOwnership)) {
            $ProxyOwnership = Db::name('advaccount')->field('advertiser_id')->where('ProxyOwnership',$ProxyOwnership)->select()->toarray();
            $ProxyOwnership_map = array_column($ProxyOwnership, 'advertiser_id'); 
            $where[] = ['advertiser_id', 'in', $ProxyOwnership_map];
        }
        
        $advinfo = $params['info_name'] ?? "";
        $where_adv = [];
        $where_adv[] = ['info', '<>', ""];
        $advinfos = Db::name('advaccount')->field('advertiser_id,info')->where($where_adv)->select()->toarray();
        $advinfos_map = array_column($advinfos, 'info',"advertiser_id"); 
        if (!empty($advinfo)) {
            $advaccount_info = Db::name('advaccount')->field('advertiser_id')->where('info', 'like', '%' . $advinfo . '%')->select()->toarray();
            $advaccount_info_map = array_column($advaccount_info, 'advertiser_id'); 
            $where[] = ['advertiser_id', 'in', $advaccount_info_map];
        }
        
        if (!empty($type_name)) {
            switch ($type_name) {
                case '1':
                    $type_name = 'API';
                    break;
                case '2':
                    $type_name = '手动录入';
                    break;
                default:
                    $type_name = 'API';
            }
            $where[] = ['type_name', '=', $type_name];
        }

        if (!empty($admin_id)) {
            $where[] = ['admin_id', '=', $admin_id];
        }
        if (!empty($shop_id)) {
            $where[] = ['shop_id', '=', $shop_id];
        }
        // halt($where);

        $list = Db::name('advertising')
            ->field('id,advertiser_id,stat_time_day,spend,impressions,platform_id,type_name,ConfirmStatus,ConfirmStatusOperate,createtime')
            ->where($where)
            ->order('stat_time_day desc,spend desc')
            ->paginate($limit);
        $lists = $list->items();
        
        foreach ($lists as $k=>$v) {
            $advaccount_admin = Db::name('advertising')  
                ->field('b.name,c.nickname')
                ->alias('a')
                ->where('a.id', '=', $v['id'])
                ->join('qu_shops b','b.id = a.shop_id', 'left')
                ->join('qu_system_admin c','c.id = a.admin_id', 'left')
                ->find();
                
            $lists[$k]['shop_name'] = $advaccount_admin['name'] ?? "";
            $lists[$k]['info_name'] = $advinfos_map[$v['advertiser_id']] ?? "";
            $lists[$k]['username'] = $advaccount_admin['nickname'] ?? "";
            switch ($v['platform_id']) {
                case '1':
                    $lists[$k]['platform'] = 'Facebook';
                    break;
                case '2':
                    $lists[$k]['platform'] = 'Google';
                    break;
                case '3':
                    $lists[$k]['platform'] = 'TikTok';
                    break;
                default:
                    $lists[$k]['platform'] = '未知';
            }
            switch ($v['ConfirmStatus']) {
                case '0':
                    $lists[$k]['ConfirmStatus'] = '等待确认';
                    break;
                case '1':
                    $lists[$k]['ConfirmStatus'] = '已确认';
                    break;
                default:
                    $lists[$k]['ConfirmStatus'] = '未知';
            }
            switch ($v['ConfirmStatusOperate']) {
                case '0':
                    $lists[$k]['ConfirmStatusOperate'] = '等待确认';
                    break;
                case '1':
                    $lists[$k]['ConfirmStatusOperate'] = '已确认';
                    break;
                default:
                    $lists[$k]['ConfirmStatus'] = '未知';
            }
            $lists[$k]['stat_time_day'] = date('Y-m-d',strtotime($v['stat_time_day']));
            if ($v['createtime'] == 0) {
                $lists[$k]['createtime'] = $lists[$k]['stat_time_day'];
            }else{
                $lists[$k]['createtime'] = date('Y-m-d H:i',$v['createtime']);
            }
            
        }
        
        $spends = Db::name('advertising')
            ->field('SUM(spend) as spend,platform_id')
            ->group('platform_id')
            ->where($where)
            ->select()->toarray();
            $spends_Total = 0;
            foreach ($spends as $k=>$v) {
                $spends_Total += (float)$v['spend'];
                switch ($v['platform_id']) {
                    case '1':
                        $spends[$k]['platform'] = 'Facebook';
                        break;
                    case '2':
                        $spends[$k]['platform'] = 'Google';
                        break;
                    case '3':
                        $spends[$k]['platform'] = 'TikTok';
                        break;
                    default:
                        $spends[$k]['platform'] = '未知';
                }
            }
            
        
        $data = [
            'list' => $lists,
            'total' => $list->total(),
            'spends' => $spends,
            'spends_Total' => getRes($spends_Total),
        ];
        return json(DefaultResponse(200, true, '获取成功', $data));
    }

    /**
     * @param $params
     * @return \think\response\Json
     * @throws \think\db\exception\DbException
     * @desc 导出
     * @author zhangheng
     */
    public function export($params = [])
    {
        $advertiser_id = $params['advertiser_id'] ?? "";
        $createtime = $params['createtime'] ?? "";
        $platform_id = $params['platform_id'] ?? 0;
        $admin_id = $params['admin_id'] ?? 0;
        $shop_id = $params['shop_id'] ?? 0;
        $type_name = $params['type_name'] ?? 0;
        $ConfirmStatus = $params['ConfirmStatus'] ?? "-1";
        $ConfirmStatusOperate = $params['ConfirmStatusOperate'] ?? "-1";
        $ProxyOwnership = $params['ProxyOwnership'] ?? "";

        // update  2024-10-24 运营产看自己账号;
        $adminId     = $params['adminId'] ?? '';
        $group_id    = $params['group_id'] ?? '';

        $where = [];
        $where[] = ['type', '=', 0];

        if (!empty($createtime)) {
            $where[] = ['stat_time', '>=', strtotime($createtime['0'])];
            $where[] = ['stat_time', '<=', strtotime($createtime['1']) + 3600*24-1];
        }else{
            // $yesterday = strtotime(date('Y-m-d', strtotime('-1 day') - timezone())); 
            // $where[] = ['stat_time', '>=', $yesterday];
            // $where[] = ['stat_time', '<=', $yesterday + 3600*24-1];
        }


        //2024-10-24  运营产看自己账号;
        if(in_array($group_id,[11,17,20,19])){
            $where['admin_id'] = $adminId;
        }
        
        //快捷时间开始
        //customDate优先
        $customDate = $params['customDate'] ?? 0;
        if(!empty($customDate)){
            switch ($customDate) {
                case '1':
                    //实时
                    $yesterday = date('Y-m-d', time() - timezone());  
                    $midnightYesterday = strtotime($yesterday . ' 00:00:00');
                    $endOfYesterday  = strtotime($yesterday . ' 23:59:59');
                    $where[]  = ['stat_time', '>=', $midnightYesterday];
                    $where[]  = ['stat_time', '<', $endOfYesterday]; 

                    break;
                case '2':
                    $yesterday = date('Y-m-d', strtotime('-1 day') - timezone());
                    $midnightYesterday = strtotime($yesterday . ' 00:00:00');
                    $endOfYesterday  = strtotime($yesterday . ' 23:59:59');
                    $where[]  = ['stat_time', '>=', $midnightYesterday];
                    $where[]  = ['stat_time', '<', $endOfYesterday]; 

                    break;
                case '3':
                    $yesterday = strtotime(date('Y-m-d', time() - timezone()));  
                    $yesterdayEnd = strtotime(date('Y-m-d', strtotime('-6 day') - timezone()));  
                    $where[] = ['stat_time', '<', $yesterday];
                    $where[] = ['stat_time', '>=', $yesterdayEnd];

                    break;
                default:
                    $yesterday = date('Y-m-d', strtotime('-1 day') - timezone());
                    $midnightYesterday = strtotime($yesterday . ' 00:00:00');
                    $endOfYesterday  = strtotime($yesterday . ' 23:59:59');
                    $where[]  = ['stat_time', '>=', $midnightYesterday];
                    $where[]  = ['stat_time', '<', $endOfYesterday]; 
            }
        }
        //快捷时间结束

        if (!empty($advertiser_id)) {
            $where[] = ['advertiser_id', 'like', '%' . $advertiser_id . '%'];
        }
        if (!empty($status)) {
            $where[] = ['status', '=', $status];
        }
        switch ($ConfirmStatus) {
            case '0':
                $where[] = ['ConfirmStatus', '=', $ConfirmStatus];
                break;
            case '1':
                $where[] = ['ConfirmStatus', '=', $ConfirmStatus];
                break;
            default:
        }
        switch ($ConfirmStatusOperate) {
            case '0':
                $where[] = ['ConfirmStatusOperate', '=', $ConfirmStatusOperate];
                break;
            case '1':
                $where[] = ['ConfirmStatusOperate', '=', $ConfirmStatusOperate];
                break;
            default:
        }
        if (!empty($platform_id)) {
            $where[] = ['platform_id', '=', $platform_id];
        }
        if (!empty($ProxyOwnership)) {
            $ProxyOwnership = Db::name('advaccount')->field('advertiser_id')->where('ProxyOwnership',$ProxyOwnership)->select()->toarray();
            $ProxyOwnership_map = array_column($ProxyOwnership, 'advertiser_id'); 
            $where[] = ['advertiser_id', 'in', $ProxyOwnership_map];
        }
        
        $advinfo = $params['info_name'] ?? "";
        $where_adv = [];
        $where_adv[] = ['info', '<>', ""];
        $advinfos = Db::name('advaccount')->field('advertiser_id,info')->where($where_adv)->select()->toarray();
        $advinfos_map = array_column($advinfos, 'info',"advertiser_id"); 
        if (!empty($advinfo)) {
            $advaccount_info = Db::name('advaccount')->field('advertiser_id')->where('info', 'like', '%' . $advinfo . '%')->select()->toarray();
            $advaccount_info_map = array_column($advaccount_info, 'advertiser_id'); 
            $where[] = ['advertiser_id', 'in', $advaccount_info_map];
        }
        
        if (!empty($type_name)) {
            switch ($type_name) {
                case '1':
                    $type_name = 'API';
                    break;
                case '2':
                    $type_name = '手动录入';
                    break;
                default:
                    $type_name = 'API';
            }
            $where[] = ['type_name', '=', $type_name];
        }

        if (!empty($admin_id)) {
            $where[] = ['admin_id', '=', $admin_id];
        }
        if (!empty($shop_id)) {
            $where[] = ['shop_id', '=', $shop_id];
        }
        // halt($where);

        $lists = Db::name('advertising')
            ->field('id,advertiser_id,stat_time_day,spend,impressions,platform_id,type_name,ConfirmStatus,ConfirmStatusOperate,createtime')
            ->where($where)
            ->order('stat_time_day desc,spend desc')
            ->select()
            ->toarray();
        foreach ($lists as &$v) {
            $advaccount_admin = Db::name('advertising')  
                ->field('b.name,c.nickname')
                ->alias('a')
                ->where('a.id', '=', $v['id'])
                ->join('qu_shops b','b.id = a.shop_id', 'left')
                ->join('qu_system_admin c','c.id = a.admin_id', 'left')
                ->find();
                
            $v['shop_name'] = $advaccount_admin['name'] ?? "";
            $v['info_name'] = $advinfos_map[$v['advertiser_id']] ?? "";
            
            $v['username'] = $advaccount_admin['nickname'] ?? "";
            switch ($v['platform_id']) {
                case '1':
                    $v['platform'] = 'Facebook';
                    break;
                case '2':
                    $v['platform'] = 'Google';
                    break;
                case '3':
                    $v['platform'] = 'TikTok';
                    break;
                default:
                    $v['platform'] = '未知';
            }
            switch ($v['ConfirmStatus']) {
                case '0':
                    $v['ConfirmStatus'] = '等待确认';
                    break;
                case '1':
                    $v['ConfirmStatus'] = '已确认';
                    break;
                default:
                    $v['ConfirmStatus'] = '未知';
            }
            switch ($v['ConfirmStatusOperate']) {
                case '0':
                    $v['ConfirmStatusOperate'] = '等待确认';
                    break;
                case '1':
                    $v['ConfirmStatusOperate'] = '已确认';
                    break;
                default:
                    $v['ConfirmStatus'] = '未知';
            }
            $v['stat_time_day'] = date('Y-m-d',strtotime($v['stat_time_day']));
            if ($v['createtime'] == 0) {
                $v['createtime'] = $v['stat_time_day'];
            }else{
                $v['createtime'] = date('Y-m-d H:i',$v['createtime']);
            }
            $v['advertiser_id'] = '广告账户:'.$v['advertiser_id'];
            
        }

        $header = [];
        $header[] = ['广告平台', 'platform'];
        $header[] = ['归属店铺', 'shop_name'];
        $header[] = ['归属人', 'username'];
        $header[] = ['广告账户', 'advertiser_id'];
        $header[] = ['广告名称', 'info_name'];
        $header[] = ['花费', 'spend'];
        $header[] = ['日期', 'stat_time_day'];
        $header[] = ['最近更新', 'createtime'];
        $header[] = ['花费类型', 'type_name'];
        $header[] = ['点击量', 'impressions'];

        $fileName = "export_Advplatform" . time();
        return Excel::exportData($lists, $header, $fileName, 'xlsx');
    }
    
    /**
     * @param $params
     * @return \think\response\Json
     * @throws \think\db\exception\DbException
     * @desc 列表
     * @author zhangheng
     */
    public function advinfo($params = [])
    {
        $limit = $params['limit'] ?? 10;
        
        $admin_id = $params['admin_id'] ?? 0;

        $date = $params['date'] ?? [];

        $where = [];
        if(!empty($date)){
            $where[]  = ['time', '>=', strtotime($date[0])];
            $where[]  = ['time', '<=', strtotime($date[1])];
            if(strtotime($date[0]) == strtotime($date[1])){
                $time = date('m-d', strtotime($date[0]));
            }else{
                $time = date('m-d', strtotime($date[0]))."至".date('m-d', strtotime($date[1]));
            }
        }

        if (!empty($admin_id)) {
            $where[] = ['admin_id', '=', $admin_id];
        }
        
        //筛选时间统计
        if(!empty($time)){
            $list = Db::name('advertising_report')
                ->field('SUM(spend) as spend,platform,admin_id,name,date')
                ->where($where)
                ->group('admin_id')
                ->order('time desc,spend desc')
                ->paginate($limit);
        }else{
            $list = Db::name('advertising_report')
                ->where($where)
                ->order('time desc,spend desc')
                ->paginate($limit);
        }
        
        $lists = $list->items();
        foreach ($lists as $k=>$v) {
            $lists[$k]['infos'] = "";
            if($v['name'] !== "未分配"){
                if(empty($date)){
                    $date[0] = $v['date'];
                    $date[1] = $v['date'];
                }
                $advertisinginfo = Db::name('advertising')
                    ->field('advertiser_id')
                    ->where('stat_time',">=",strtotime($date[0]))
                    ->where('stat_time',"<=",strtotime($date[1]))
                    ->where('spend',">=",0.001)
                    ->where('type',"=",0)
                    ->where('admin_id',$v['admin_id'])
                    ->group('advertiser_id')
                    ->select()->toarray();
                if(!empty($advertisinginfo)){
                    //转换成字符串，用逗号分隔
                    $advertisinginfos = implode(',',array_column($advertisinginfo,'advertiser_id'));
                    $lists[$k]['infos'] = $advertisinginfos;
                }
            }
            if(!empty($time)){
                $lists[$k]['date'] = $time;
            }
            switch ($v['platform']) {
                case '1':
                    $lists[$k]['platform'] = 'Facebook';
                    break;
                case '2':
                    $lists[$k]['platform'] = 'Google';
                    break;
                case '3':
                    $lists[$k]['platform'] = 'TikTok';
                    break;
                default:
                    $lists[$k]['platform'] = '未知';
            }
        }
        
        $data = [
            'list' => $lists,
            'total' => $list->total(),
        ];
        return json(DefaultResponse(200, true, '获取成功', $data));
    }

    
    public function add($data = [])
    {
        if (!$data) {
            return json(DefaultResponse(201, false, '参数不能为空!', null));
        }
        $result = false;
        if((float)$data['spend'] <= 0.01){
            return json(DefaultResponse(201, true, '广告花费错误!', null));
        }
        try {
            $insert['stat_time'] = strtotime($data['createtime']);
            $insert['advertiser_id'] = $data['advertiser_id'];
            $insert['platform_id'] = $data['platform_id'];
            $insert['spend'] = (float)$data['spend'];
            $insert['stat_time_day'] = date('Y-m-d 00:00:00', $insert['stat_time']);
            $insert['type_name'] = "手动录入";
            $insert['ConfirmStatus'] = 1;
            $insert['type'] = 0;



            $advertising = Db::name('advertising')
                ->where('advertiser_id',$insert['advertiser_id'])
                ->where('stat_time',$insert['stat_time'])
                ->where('type',0)
                ->find();
            if(!empty($advertising)){
                return json(DefaultResponse(201, true, '该广告账户花费已存在!', null));
            }
            $result = Db::name('advertising')->insert($insert);
            
            htmlLog(['advertising'=>$insert],OPERATE_LOG . date('Ym') . '/AdvertisingInsert/' . date('Ymd') . '.txt');

            if ($result !== false) {
                return json(DefaultResponse(200, true, '添加成功!', null));
            } else {
                return json(DefaultResponse(201, false, '添加失败!', null));
            }
        } catch (ValidateException $e) {
            return json(DefaultResponse(201, false, $e->getError(), null));
        } catch (\Exception $e) {
            return json(DefaultResponse(201, false, '添加失败!', null));
        }
        return json(DefaultResponse(200, false, '更新成功!', null));

    }

    public function find($id)
    {
        $row = Db::name('advertising')
            ->field('id,advertiser_id,spend,stat_time_day as createtime,platform_id,stat_time')
            ->where('id',$id)
            ->find();
        if (empty($row)) {
            return json(DefaultResponse(201, false, '数据不存在!', null));
        }
        return json(DefaultResponse(200, true, '获取成功', $row));
    }

    public function edit($data = [])
    {
        if (!$data) {
            return json(DefaultResponse(201, false, '参数不能为空!', null));
        }
        $id = $data['id'];
        if (empty($id)) {
            return json(DefaultResponse(201, false, '数据不存在!', null));
        }
        $result = false;

        try {
            $advertising = Db::name('advertising')
                ->where('id',$data['id'])
                ->find();
            if ($advertising['type_name'] == "API") {
                return json(DefaultResponse(201, false, 'API数据不能修改!', null));
            }

            $update['stat_time'] = strtotime($data['createtime']);
            $update['stat_time_day'] = date('Y-m-d 00:00:00', $update['stat_time']);
            $update['type_name'] = "手动录入";
            $insert['ConfirmStatus'] = 1;
            $insert['type'] = 0;
            $update['platform_id'] = $data['platform_id'];
            $update['spend'] = (float)$data['spend'];
            $result = Db::name('advertising')
                ->where('id',$data['id'])
                ->update($update);

            if ($result) {
                return json(DefaultResponse(200, false, '更新成功!', null));
            }
            return json(DefaultResponse(201, false, '更新失败!', null));
        } catch (ValidateException $e) {
            return json(DefaultResponse(201, false, $e->getError(), null));
        } catch (\Exception $e) {
            return json(DefaultResponse(201, false, '更新失败!', null));
        }
        return json(DefaultResponse(200, false, '更新成功!', null));
    }


    public function confirm($data = [])
    {
        if (!$data) {
            return json(DefaultResponse(201, false, '参数不能为空!', null));
        }
        $id = $data['id'];
        if (empty($id)) {
            return json(DefaultResponse(201, false, '数据不存在!', null));
        }
        $result = false;

        $group_id    = $data['group_id'] ?? '';

        try {
            
            if(in_array($group_id,[11,17,20,19])){
                $update['ConfirmStatusOperate'] = 1;
            }else{
                $update['ConfirmStatus'] = 1;
            }
            $result = Db::name('advertising')
                ->where('id',$data['id'])
                ->update($update);

            if ($result) {
                return json(DefaultResponse(200, false, '操作成功!', null));
            }
            return json(DefaultResponse(201, false, '操作失败!', null));
        } catch (ValidateException $e) {
            return json(DefaultResponse(201, false, $e->getError(), null));
        } catch (\Exception $e) {
            return json(DefaultResponse(201, false, '操作失败!', null));
        }
        return json(DefaultResponse(200, false, '操作成功!', null));
    }

}
